home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / pcboard / msgtag11.zip / KILL.PPS < prev    next >
Text File  |  1996-01-30  |  6KB  |  201 lines

  1. ; KILL.PPE by Dan Shore - SysOp
  2. ;             The Shoreline BBS
  3. ;
  4. ; Purpose:  This PPE will allow the KILL command to accept more than
  5. ;           one message number at a time.
  6. ;
  7. ;           KILL.PPE will accept multiple numbers or ranges of numbers
  8. ;           either when stacking at the main command line or when
  9. ;           prompted for "Enter message number to kill".
  10. ;
  11. ;           For example: "1 2 3"  or  "1-3"  are acceptable entries.
  12. ;
  13. ;──────────────────────────────────────────────────────────────────────────────
  14. ;
  15. ; Revised on  :  11/02/95
  16. ; Revised by  :  Dan Shore
  17. ; Purpose     :  Modification due to PCB TOKCOUNT and GETTOKEN()
  18. ;                limitations of only reading upto the 256th
  19. ;                character of a BIGSTR
  20. ;
  21. ;──────────────────────────────────────────────────────────────────────────────
  22. ;
  23. ; To install:
  24. ;
  25. ;    1) Edit your CMD.LST file(s) to add this:
  26. ;
  27. ;                             Charges Per     PPE/MNU File Specification -or-
  28. ;            Command    Sec  Minute    Use    Keystroke Substitution
  29. ;        ══════════════ ═══ ═════════════════ ═════════════════════════════════
  30. ;     1) K                5        0        0 C:\PCB\PPE\KILL\KILL.PPE
  31. ;
  32. ;       Note: You may have to change the pathname to the PPE.
  33. ;
  34. ;
  35. ;───────────────────────────────────────────────────────────────────────────
  36. STRING main_prompt       ' Generic input prompt
  37. STRING stack_var         ' used for parsing stacked input
  38. STRING temp_var          ' used when parsing range input
  39. STRING hold              ' Generic string variable
  40. STRING temp              ' Generic string variable
  41. STRING tag_msg_file      ' Path/filename of tagged msgs
  42.  
  43. BIGSTR user_input        ' Generic user input - used also to hold tag list
  44.  
  45. INTEGER hold_num         ' Generic integer used for range input
  46. INTEGER count            ' counts command line parms
  47. INTEGER start            ' starting number of range
  48. INTEGER end              ' ending number of range
  49.  
  50. BOOLEAN tagged_files     ' TRUE if there are files tagged
  51. ;───────────────────────────────────────────────────────────────────────────
  52.  
  53. :MAIN
  54.  
  55.   '
  56.   '  Get path to swap file directory
  57.   '
  58.   hold = READLINE(PCBDAT(),204)
  59.   hold = FILEINF(hold,6) + ":" + FILEINF(hold,7)
  60.  
  61.   '
  62.   '  Determine paths and names of files used by KILL.PPE
  63.   '
  64.   tag_msg_file = hold + "mtg" + STRING(CURCONF()) + ".lst"
  65.  
  66.   '
  67.   '  Count command line paramaters (stacked)
  68.   '
  69.   count = TOKCOUNT()
  70.  
  71.   '
  72.   '  If there are no stacked commands display KILL Msg prompt and
  73.   '  get their response
  74.   '
  75.   IF (count < 1) THEN
  76.     IF (EXIST(tag_msg_file)) THEN
  77.       IF (FILEINF(tag_msg_file,4) > 0) tagged_files = TRUE
  78.     END IF
  79.     PRINTLN "@X0F*@X0D────────────────────────────────────────@X0F*"
  80.     PRINTLN " @X0BEnter single numbers @X0F(@X0E1 4 9@X0F)@X0B or enter"
  81.     PRINTLN " @X0Branges @X0F(@X0E1-4 6-12@X0F)@X0B of msg #'s to kill@X07"
  82.     NEWLINE
  83.     PRINTLN "      @X03Low Message Number@X0F :@X0E ", LOMSGNUM()
  84.     PRINTLN "      @X03High Message Number@X0F:@X0E ", HIMSGNUM()
  85.     PRINTLN "@X0F*@X0D────────────────────────────────────────@X0F*"
  86.     '
  87.     '  Use a different prompt when there are tagged msgs
  88.     '
  89.     IF (tagged_files) THEN
  90.       main_prompt = "@X0AEnter the Message #(s) to Kill, @X02(@X0FTAG@X02)=@X03@X0BTagged @X03Msgs, @X0F(Enter)=none@X07"
  91.     ELSE
  92.       main_prompt = "@X0AEnter the Message #(s) to Kill @X0F(Enter)=none@X07"
  93.     END IF
  94.     INPUTSTR main_prompt, user_input, @X0E, 50, " ;0123456789-DELTAG", LFAFTER+UPCASE
  95.     IF (user_input = "") GOTO EXIT_PROG
  96.     IF (user_input = "TAG") GOSUB PROCESS_TAGGED
  97.     user_input = REPLACESTR(user_input, " ", ";")
  98.     IF (RIGHT(user_input,1) != ";") user_input = user_input + ";"
  99.   ELSE
  100.     '
  101.     '  Process stacked commands
  102.     '
  103.     WHILE (1) DO
  104.       hold = GETTOKEN()
  105.       IF (hold = "") BREAK
  106.       user_input = user_input + hold + ";"
  107.     END WHILE
  108.     '
  109.     '  If ranges of numbers entered, process them in the subroutine to
  110.     '  convert them to a string of numbers instead of ranges.
  111.     '  5-10 converts to 5 6 7 8 9 10
  112.     '
  113.     IF (INSTR(user_input,"-") > 1) GOSUB CHECK_NUMBER_RANGE
  114.     '
  115.   END IF
  116.  
  117.   '
  118.   '  Process user_input until there are no more entries, then exit program
  119.   '
  120.   WHILE (1) DO
  121.     hold = MID(user_input, 1, INSTR(user_input, ";")-1)
  122.     user_input = MID(user_input, INSTR(user_input, ";")+1, LEN(user_input)-INSTR(user_input,";"))
  123.     IF (hold = "") BREAK
  124.     COMMAND FALSE, "K " + hold
  125.   END WHILE
  126.   GOTO EXIT_PROG
  127.  
  128. :END_MAIN
  129.  
  130. '
  131. '  Read disk file of tagged msgs into user_input
  132. '
  133. :PROCESS_TAGGED
  134.  
  135.    FOPEN 1, tag_msg_file, O_RD, S_DN
  136.    FREAD 1, user_input, FILEINF(tag_msg_file,4)
  137.    FCLOSE 1
  138.    RETURN
  139.  
  140. '
  141. '
  142. '
  143. :EXIT_PROG
  144.  
  145.   KBDSTUFF CHR(13)
  146.   END
  147.  
  148. '
  149. '  See if user entered a "range" of msg numbers to kill
  150. '
  151. :CHECK_NUMBER_RANGE
  152.  
  153.    '
  154.    '  Put "user_input" into "stack_var" as we are going to rebuild
  155.    '  user_input with acutal numbers instead of the range the user
  156.    '  has entered
  157.    '
  158.    stack_var = user_input
  159.    user_input = ""
  160.  
  161.    '
  162.    '  Tokenize stack_var so we can process it one entry at a time
  163.    '
  164.    TOKENIZE stack_var
  165.    IF (TOKCOUNT() = 0) RETURN
  166.    FOR hold_num = 1 TO LEN(stack_var)
  167.      end = 0
  168.      start = 0
  169.      temp_var = GETTOKEN()
  170.      IF (temp_var = "") BREAK
  171.      IF (INSTR(temp_var, "-") = 0) THEN
  172.        user_input = user_input + temp_var + ";"
  173.      ELSE
  174.        '
  175.        '  Input had a "-" in it, so lets process the range request
  176.        '
  177.        start = S2I(MID(temp_var, 1, INSTR(temp_var,"-")-1),10)
  178.        IF (start) end = S2I(MID(temp_var, INSTR(temp_var,"-")+1, LEN(temp_var)),10)
  179.  
  180.        '
  181.        '  This loop will run from "start" number to "end" number and
  182.        '  build the "user_input" variable with the acutal numbers.  For
  183.        '  instance an input of "5-10" would equate to "5 6 7 8 9 10 "
  184.        '  in user_input.
  185.        '
  186.        IF (end >= start) THEN
  187.          FOR count = start TO end
  188.            user_input = user_input + STRING(count) + ";"
  189.          NEXT
  190.        ELSE
  191.          '
  192.          '  If "end" is less than "start" tell the user that it is
  193.          '  and invalid input and the entry was not processed.
  194.          '
  195.          NEWLINE
  196.          PRINTLN "@X0FEnding value is less than Starting value @X0E(@X0CEntry not processed@X0E)@X07"
  197.        END IF
  198.      END IF
  199.    NEXT
  200.    RETURN
  201.